package controler;


import java.io.Serializable;
import java.util.Collection;

import view.ListView;
import ema.tpjee.banking.dao.SessionFacade;
import ema.tpjee.banking.model.Bank;



public class BankControler implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -1645348478746136298L;
	//private BankApplicationDaoImpl dao_;

	private ListView view = new ListView();
	private SessionFacade sessionFacade;

	
	public Collection<Bank> getBanks() {
		return sessionFacade.getBankDao().listBank();
	}

	public void setBanks(Collection<Bank> dumm) {

	}

	public void setView(ListView dumm) {
		//this.view = view;
	}
	
	public ListView getView() {
		return view;
	}

	public void add(Bank b) {
		sessionFacade.getBankDao().addBank(b);
	}
	
	public String applyCustomer() {
		System.out.println("apply");
		return "edit_customer";
	}
	
	public String cancelBank() {
		System.out.println("cancel");
		return "list_bank";
	}
	
	public String createBank() {
		System.out.println("create");
		//currentBank = null;
		//newBank();
		//currentBank = dao_.newBank();
		sessionFacade.newBank();
		return "edit_bank";
	}
	
	public String saveBank(){
		System.out.println("save");
		//saveBank(currentBank);
		return "list_bank";
	}
	
	public String deleteBank(){
		System.out.println("delete");		
		//deleteBank(currentBank);
		//currentBank = getBanks().get(0);
		//currentBank = dao_.deleteBank(currentBank);
		sessionFacade.deleteBank();
		return "list_bank";
	}	
	
	public String editBank() {
		System.out.println("edit");
		String bankId=view.getIdCmdValue();
		System.out.println(bankId);
		//currentBank = getBankById(bankId);
		//currentBank = dao_.findBank(Integer.parseInt(bankId));
		sessionFacade.findBank(Integer.parseInt(bankId));
		return "edit_bank";
	}
	
	public String showCustomers() {
		System.out.println("showCustomers");
		return "list_customer";
	}


}
